/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

$(function () {
    //确认付款
    $('#qrfk').click(function () {
        var items = $("input[name=radio1]:checked");
        var flag = false;
        var id = null;
        var wfk = null;
        if (items.length == 0) {
            flag = true;
        } else {
            $("input[name=radio1]:checked").each(function () {

                id = ($(this).val()).split("-")[0];
                wfk = ($(this).val()).split("-")[1];


            });
        }
        if (flag) {
            $.toast("请选择一条数据！", "forbidden");
        } else {
            var text = "请输入付款金额，请不要超过" + wfk + "元";
            $.prompt({
                title: '确定付款金额',
                text: text,
                input: wfk,
                empty: true, // 是否允许为空
                onOK: function (je) {
                    if (je > wfk||je=="") {
                    $.toast("输入数据有误！", "forbidden");
                } else {
                    $.showLoading();
                    var o = new AjaxOptions();
                    o.put('service_code', 'P90004');
                    o.put('id', id);
                    o.put('je', je);
                    o.sus = function (data) {
                        $.hideLoading();
                        $.toast("操作成功!");
                        $('#form').submit();
                    };
                    o.fal = function (code, desc) {
                        $.hideLoading();
                        if (code == "9000401") {
                            $.toast("确认付款失败！", "forbidden");
                        }
                    };
                    $.ajax(o);
                }
            },
                onCancel: function () {
                    
                }
            });
        }
    });
});
function xsxq() {
    var items = $("input[name=radio1]:checked");
    if (items.length == 0 || items.length > 1) {
        $.alert("请选择一条数据查看详情");
    } else {
        var id = ($("input[name=radio1]:checked").val()).split("-")[0];
        var o = new AjaxOptions();
        o.put('service_code', 'P90005');
        o.put('id', id);
        o.sus = function (data) {
            var xq = data.xq;
            var ssrq  = (xq.shrq).substring(0,10);
            var text = "<div class='weui_cell'>" +
                    "<div class='weui_cell_hd'><label style='width: 100px' class='weui_label'>花木名称:</label></div>" +
                    "<div class='weui_cell_bd weui_cell_primary'>" +
                    "<input  class='weui_input' value='" + xq.hmlx_ + "' readonly='readonly'></div></div>" +
                    "<div class='weui_cell'>" +
                    "<div class='weui_cell_hd'><label style='width: 100px' class='weui_label'>单价(元):</label></div>" +
                    "<div class='weui_cell_bd weui_cell_primary'>" +
                    "<input  class='weui_input' value='" + xq.dj + "'  readonly='readonly'></div></div>" +
                    "<div class='weui_cell'>" +
                    "<div class='weui_cell_hd'><label style='width: 100px' class='weui_label'>数&nbsp;&nbsp;&nbsp;&nbsp;量:</label></div>" +
                    "<div class='weui_cell_bd weui_cell_primary'>" +
                    "<input  class='weui_input' value='" + xq.ss + "' readonly='readonly'></div></div>" +
                    "<div class='weui_cell'>" +
                    "<div class='weui_cell_hd'><label style='width: 100px' class='weui_label'>总&nbsp;&nbsp;&nbsp;&nbsp;价:</label></div>" +
                    "<div class='weui_cell_bd weui_cell_primary'>" +
                    "<input  class='weui_input' value='" + xq.zj + "' readonly='readonly'></div></div>" +
                    "<div class='weui_cell'>" +
                    "<div class='weui_cell_hd'><label style='width: 100px' class='weui_label'>花木所有人:</label></div>" +
                    "<div class='weui_cell_bd weui_cell_primary'>" +
                    "<input  class='weui_input' value='" + xq.hmsyr + "' readonly='readonly'></div></div>" +
                    "<div class='weui_cell'>" +
                    "<div class='weui_cell_hd'><label style='width: 100px' class='weui_label'>已付款金额:</label></div>" +
                    "<div class='weui_cell_bd weui_cell_primary'>" +
                    "<input  class='weui_input' value='" + xq.yfk + "' readonly='readonly'></div></div>" +
                    "<div class='weui_cell'>" +
                    "<div class='weui_cell_hd'><label style='width: 100px' class='weui_label'>未付款金额:</label></div>" +
                    "<div class='weui_cell_bd weui_cell_primary'>" +
                    "<input  class='weui_input' value='" + xq.wfk + "' readonly='readonly'></div></div>" +
                    "<div class='weui_cell'>" +
                    "<div class='weui_cell_hd'><label style='width: 100px' class='weui_label'>花木运送地:</label></div>" +
                    "<div class='weui_cell_bd weui_cell_primary'>" +
                    "<input  class='weui_input' value='" + xq.hmysgd_ + "' readonly='readonly'></div></div>" +
                    "<div class='weui_cell'>" +
                    "<div class='weui_cell_hd'><label style='width: 100px' class='weui_label'>收树日期:</label></div>" +
                    "<div class='weui_cell_bd weui_cell_primary'>" +
                    "<input  class='weui_input' value='" + ssrq + "' readonly='readonly'></div></div>" +
                    "<div class='weui_cell'>" +
                    "<div class='weui_cell_hd'><label style='width: 100px' class='weui_label'>备&nbsp;&nbsp;&nbsp;&nbsp;注:</label></div>" +
                    "<div class='weui_cell_bd weui_cell_primary'>" +
                    "<input  class='weui_input' value='" + xq.bz + "' readonly='readonly'></div></div>";
            if (xq.pic != '') {
                text += "<div class='weui_cell'>" +
                        "<div class='weui_cell_hd'><label style='width: 100px' class='weui_label'>附&nbsp;&nbsp;&nbsp;&nbsp;图:</label></div>" +
                        "<div class='weui_cell_bd weui_cell_primary'>" +
                        "<a href='http://alyun.jtgzfw.com:8780/wcjz_temp/image/" + xq.pic + ".jpg' class='weui_btn weui_btn_mini weui_btn_primary'>查看附图</a></div></div>";
            }


            $.modal({
                title: "账单详情",
                text: text,
                autoClose: true,
                buttons: [
                    {text: "关闭", onClick: function () {

                        }},
                ]

            });
            $('.weui_dialog').css('margin-top', '-180px');

        };
        o.fal = function (code, desc) {
            $.toast("获取详情失败！", "forbidden");
        };
        $.ajax(o);

    }
}


        